package mlz.c_newDateClass;

import java.time.Duration;
import java.time.LocalDateTime;

//Duration:计算时间间隔类 时分秒
public class DurationDemo08 {
    public static void main(String[] args) {
        //获取指定时间
        LocalDateTime time1 = LocalDateTime.of(2025, 11, 11, 11, 11, 11);
        LocalDateTime time2 = LocalDateTime.of(2099, 10, 2, 6, 10, 1);

        //获取duration对象
        Duration duration = Duration.between(time1, time2);

        //获取两个时间对象之间间隔的信息
        System.out.println(duration.toDays());//间隔天数
        System.out.println(duration.toHours());//间隔小时
        System.out.println(duration.toMinutes());//间隔分钟
        System.out.println(duration.toSeconds());//间隔秒
        System.out.println(duration.toMillis());//间隔毫秒
        System.out.println(duration.toNanos());//间隔纳秒
    }
}








